package com.example.customview;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.example.customview.activity.ColorTrackTextActivity;
import com.example.customview.activity.ProgressBarActivity;
import com.example.customview.activity.QQStepActivity;
import com.example.customview.activity.RecyclerViewActivity;
import com.example.customview.activity.ShapeActivity;
import com.example.customview.activity.ShowActivity;
import com.example.customview.view.ProgressBarView;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    private final static String TAG = "MainActivity";

    private Button mCustomViewButton;

    private Button mQQStepViewButton;

    private Button mColorTrackTextView;

    private Button mProgressBarView;

    private Button mShapeView;
    private Button mRecyclerView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        mCustomViewButton = findViewById(R.id.custom_view_button);
        mQQStepViewButton = findViewById(R.id.qq_step_button);
        mColorTrackTextView = findViewById(R.id.color_track_text_view);
        mProgressBarView = findViewById(R.id.color_progress_bar_view);
        mShapeView = findViewById(R.id.color_shape_view);
        mRecyclerView = findViewById(R.id.color_recycler_view);
        setOnClick();
    }

    private void setOnClick(){
        mCustomViewButton.setOnClickListener(this::onClick);
        mQQStepViewButton.setOnClickListener(this::onClick);
        mColorTrackTextView.setOnClickListener(this::onClick);
        mProgressBarView.setOnClickListener(this::onClick);
        mShapeView.setOnClickListener(this::onClick);
        mRecyclerView.setOnClickListener(this::onClick);
    }


    @Override
    public void onClick(View view) {
        Intent intent = new Intent();
        switch (view.getId()){
            case R.id.custom_view_button:
                intent.setClass(this , ShowActivity.class);
                startActivity(intent);
                break;
            case R.id.qq_step_button:
                Log.i(TAG,"qq_step_button");
                intent.setClass(this, QQStepActivity.class);
                startActivity(intent);
                break;
            case R.id.color_track_text_view:
                Log.i(TAG,"color_track_text_view");
                intent.setClass(this, ColorTrackTextActivity.class);
                startActivity(intent);
                break;
            case R.id.color_progress_bar_view:
                Log.i(TAG,"color_progress_bar_view");
                intent.setClass(this, ProgressBarActivity.class);
                startActivity(intent);
                break;
            case R.id.color_shape_view:
                Log.i(TAG,"color_shape_view");
                intent.setClass(this, ShapeActivity.class);
                startActivity(intent);
                break;
            case R.id.color_recycler_view:
                Log.i(TAG,"color_recycler_view");
                intent.setClass(this, RecyclerViewActivity.class);
                startActivity(intent);
                break;
            default:
                Log.i(TAG,"onClick is of no avail");
        }
    }
}